var express = require("express"); //创建一个Express应用程序。该express()函数是express模块导出的顶级函数。
var router = express.Router(); //创建一个新的路由器对象。
const mysql = require("mysql");
//登录
var connection = mysql.createConnection({
  host: "127.0.0.1", //主机地址（默认为：localhost）
  user: "root", //用户名
  password: "wang123123", //密码
  port: "13306",
  database: "feigeroom", //数据库名
});

connection.connect();
var ifOk = true;
const account = "19531825454";
const password = "aka123456";
connection.query(
  `SELECT title, size, area, price, unit_price,floor, image FROM room WHERE renovation = ${keyword}`,
  function (err, results) {
    if (err) return console.log(err.message);

    console.log(results); //JSON.stringify(results)
    //  res.send(results);

    //在根路由（/）（应用程序的主页）上响应get请求
    router.get("/", (req, res) => {
      res.send(results);
    });
  }
);

// module.exports = router; //原生模块化语法   module.export     require('../xxxx')

const roomA = {
  village: "维多利高级公寓",
};
connection.query(
  `SELECT * FROM room WHERE room.area >= ${min} And room.area <= ${max}`,
  function (err, results) {
    if (err) return console.log(err.message);

    console.log(results); //JSON.stringify(results)
    //  res.send(results);

    //在根路由（/）（应用程序的主页）上响应get请求
    router.get("/", (req, res) => {
      res.send(results);
    });
  }
);

module.exports = router; //原生模块化语法   module.export     require('../xxxx')
